﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace NAGFwk.UI
{
    public static class ModelAssemblyHelper
    {
        static Assembly modelAssembly = null;
        public static Assembly ModelAssembly
        {
            get
            {
                if (modelAssembly == null)
                    modelAssembly = typeof(ModelAssemblyHelper).Assembly;
                return modelAssembly;
            }
        }
        static string[] resourceNames = null;
        public static string GetResourcePath(string resourceName)
        {
            if (resourceNames == null)
                resourceNames = ModelAssembly.GetManifestResourceNames();

            var result = resourceNames.Single(x => x.EndsWith(resourceName));

            return result;
        }
        public static Stream GetResourceStream(string resourceName)
        {
            return ModelAssembly.GetManifestResourceStream(GetResourcePath(resourceName));
        }
    }
}
